home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / plain C OS8 / Gadgets / GadgetsEngine.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-29  |  2.3 KB  |  111 lines  |  [TEXT/CWIE]

  1. /* GadgetsEngine.c -- application-specific data management */
  2.  
  3. /* This module contains data structures to access the data in your */
  4. /* document's file(s). The purpose is to isolate the details of the */
  5. /* data representation into this module and to provide accessor */
  6. /* functions for reading/writing logical pieces of the data. */
  7. /* For your application, you will probably rewrite most of this. */
  8. /* This module will not be regenerated by AppMaker unless you delete it. */
  9.  
  10. #include <Types.h>
  11. #include <Quickdraw.h>
  12. #include <Controls.h>
  13. #include <Events.h>
  14. #include <Lists.h>
  15. #include <Menus.h>
  16. #include <TextEdit.h>
  17. #include <stdlib.h>
  18.  
  19. #include "Dispatcher.h"
  20. #include "DDocData.h"
  21. #include "Globals.h"
  22. #include "Miscellany.h"
  23. #include "GadgetsEngine.h"
  24.  
  25.  
  26. //----------
  27. GadgetsEngine*        NewGadgetsEngine ()
  28. {
  29.     GadgetsEngine*        engine;
  30.  
  31.     engine = (GadgetsEngine*)malloc (sizeof (GadgetsEngine));
  32.     GadgetsEngine_Init (engine);
  33.     SetClassID (engine, classGadgetsEngine);
  34.  
  35.     return engine;
  36. }
  37.  
  38. //----------
  39. void    DeleteEngine (
  40.     AMEngine*        engine)
  41. {
  42.     GadgetsEngine_Free ((GadgetsEngine*)engine);
  43.     free (engine);
  44. }
  45.  
  46. //----------
  47. void    GadgetsEngine_Init (
  48.     GadgetsEngine*        self)
  49. {
  50.     AMEngine_Init ((AMEngine*) self);
  51.  
  52.     self->super.mFileType = kFileType;
  53.     self->super.mSignature = kSignature;
  54. }
  55.  
  56. //----------
  57. void    GadgetsEngine_Free (
  58.     GadgetsEngine*        self)
  59. {
  60.     AMEngine_Free ((AMEngine*) self);
  61. }
  62.  
  63. // These are just models for your own data access functions.
  64. // Replace them with ones that do something useful.
  65.  
  66. /*----------*/
  67. DDocData*    GetDocData (
  68.     GadgetsEngine*        self)
  69. {
  70.     return NewDDocData ();
  71. }
  72.  
  73. //----------
  74. void    InitData (
  75.     AMEngine*        engine)
  76. {
  77.     GadgetsEngine*        self = (GadgetsEngine*) engine;
  78.  
  79.     // override to initialize your data structures
  80. }
  81.  
  82. //----------
  83. void    DisposeData (
  84.     AMEngine*        engine)
  85. {
  86.     GadgetsEngine*        self = (GadgetsEngine*) engine;
  87.  
  88.     // override to dispose your data structures
  89. }
  90.  
  91. //----------
  92. void    ReadFile (
  93.     AMEngine*        engine)
  94. {
  95.     GadgetsEngine*        self = (GadgetsEngine*) engine;
  96.  
  97.     InitData (engine);
  98.     engine->mDirty = false;
  99.     // override to read from the current file into your data structures
  100. }
  101.  
  102. //----------
  103. void    WriteFile (
  104.     AMEngine*        engine)
  105. {
  106.     GadgetsEngine*        self = (GadgetsEngine*) engine;
  107.  
  108.     engine->mDirty = false;
  109.     // override to write your data structures to the current file
  110. }
  111.